<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'update_book.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/application.css"></c:url>">
    <link rel="stylesheet" type="text/css" href="<c:url value="/css/form.css"></c:url>">
    <style>
       #imgPreview{
         width:350px;
         height:350px;
         position:absolute;
         top:60px;
         right:100px;
       }
    </style>
    
       <script type="text/javascript">
		function PreviewImage(imgFile) {
		
			var filextension = imgFile.value.substring(imgFile.value.lastIndexOf("."), imgFile.value.length);
			filextension = filextension.toLowerCase();
			
			if ((filextension != '.jpg') && (filextension != '.gif')
					&& (filextension != '.jpeg') && (filextension != '.png')
					&& (filextension != '.bmp')) {
				alert("对不起，系统仅支持标准格式的照片，请您调整格式后重新上传，谢谢 !");
				imgFile.focus();
			} 
			else {
				var path;
				if (document.all)//IE 
				{
					imgFile.select();
					path = document.selection.createRange().text;
					document.getElementById("imgPreview").innerHTML = "";
					document.getElementById("imgPreview").style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='scale',src=\""
							+ path + "\")";//使用滤镜效果 
				} else//FF 
				{
					path = imgFile.files[0].getAsDataURL();
					document.getElementById("imgPreview").innerHTML = "<image id='bookcover'src='"+path+"'/>";
				}
			}			
		}
	</script>
  </head>
  
  <body>
     <form action="<c:url value="/bookMgr"/>" method="post" enctype="multipart/form-data">
       <input type="hidden" name="act" value="update"/>
       <input type="hidden" name="bookcode" value="${book.bookCode}"/>
       <input type="hidden" name="bookMark" value="${book.bookMark}"/>
       <div class="headTitle">&gt;&gt;修改图书信息</div>
       <div class="groupline" style="margin-bottom:5px">图书基本信息</div>
       <div>
	       <ul>
	          <li>
	            <span class="lableFont">ISBN编号:</span>
	            ${book.bookCode}
	          </li>
	          <li>
	            <span class="lableFont">图书名称:</span>
	            <input type="text" class="text" name="bookname" size="80" value="${book.bookName}"/>
	          </li>
	          <li>
	             <span class="lableFont">封面图片:</span>
	              <input type="file" class="text" name="bookimage" size="80" onchange='PreviewImage(this);'/>
	          
	          </li>
	          <li>
	            <span class="lableFont">所属类别:</span>
	            <select name="bookCtg">
	            <option value="0">==请选择==</option>
	            <c:forEach var="ctg" items="${ctgs}">
	               <option value="${ctg.ctgId}" <c:if test="${book.ctg.ctgId==ctg.ctgId}">selected</c:if>>${ctg.ctgName}</option>
	            </c:forEach>
                </select>
	          </li>
	          <li>
	            <span class="lableFont">图书单价:</span>
	            <input type="text" class="text" name="bookprice" value="${book.bookPrice}"/>
	          </li>
	          <li>
	            <span class="lableFont">图书作者:</span>
	            <input type="text" class="text" name="bookauthor" size="30" value="${book.bookAuthor}"/>
	          </li>
	          <li>
	            <span class="lableFont">出版单位:</span>
	            <input type="text" class="text" name="bookpublisher" size="50"  value="${book.bookPublisher}"/>
	          </li>
	          <li>
	            <span class="lableFont">出版日期:</span>
	            <input type="text" class="text" name="bookpubdate" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${book.bookPubDate}"/>"/>
	          </li>
	          <li>
	            <span class="lableFont" style="vertical-align:middle">内容简介:</span>
	            <textarea name="bookdesc" class="text" rows="15" cols="100">${book.bookDesc}</textarea>
	          </li>	 
	        </ul> 
          </div>
          <div id="imgPreview"> 
             <image id="bookcover" src="<c:url value="/bookMgr?act=showcover&bookcode=${book.bookCode}"/>"/>
          </div> 
	      <div class="submitDiv">
	        <input type="submit" value="图书登记"/>
	        <input type="reset" value="取消重写"/>
	      </div>     
    </form>
       <c:if test="${not empty errMsg}">
          <script type="text/javascript">
             alert("${errMsg}");
          </script>
       </c:if>
    
  </body>
</html>
